var opened_box=null;
var loading_box=false;
function gradient(id, level)
{
	var box = $(id);
	box.style.opacity = level;
	box.style.MozOpacity = level;
	box.style.KhtmlOpacity = level;
	box.style.filter = "alpha(opacity=" + level * 100 + ")";
	box.style.display="block";
	return;
}


function fadein(id) 
{
	var level = 0;
	while(level <= 1)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level += 0.01;
	}
}

function fadeout(id)
{
	var level = 1;
	while(level >= 0)
	{
		setTimeout( "gradient('" + id + "'," + level + ")", (level* 1000) + 10);
		level -= 0.01;
	}
}


// Open the lightbox

function closebox(formtitle,fadout) {
    var box = $('box');
    $('filter').style.display='none';
    if(fadout)
  {
	 gradient("box", 0);
	 fadeout("box");
  }
  else
  {
    box.style.display='none';
  }
}

function openbox(formtitle, fadin)
{
  if (formtitle=='Inscription') {
      $("adresse_mail").setStyle({'display':'block'});
      $("mot_de_passe_conf").setStyle({'display':'block'});
      $("box").setStyle({'height':'240px'});
  }
  else { // Connexion
      $("adresse_mail").setStyle({'display':'none'});
      $("mot_de_passe_conf").setStyle({'display':'none'});
      $("box").setStyle({'height':'140px'});
  }
  if (loading_box)
      return;
  closebox(opened_box,0);
  loading_box=true;
  opened_box=formtitle;
  var box = $('box');
  $('filter').style.display='block';

  var thetitle = $('the_title');
  thetitle.update('&nbsp;&nbsp;&nbsp;'+formtitle);
  
  if(fadin)
  {
	 gradient("box", 0);
	 fadein("box");
  }
  else
  { 	
    box.style.display='block';
  }
  loading_box=false;
}


// Close the lightbox

function closebox()
{
   $('box').style.display='none';
   $('filter').style.display='none';
}



